package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Carousel;
import com.example.Laboratory.Service.CarouselService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(value = "轮播图",description = "轮播图")
@RestController
@RequestMapping("/Carousel")
@CrossOrigin
public class CarouselController {

    @Autowired
    CarouselService carouselService;

    @ApiOperation(value = "添加轮播图",notes = "添加轮播图")
    @RequestMapping(value = "/addCarousel",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Object addCarousel(MultipartFile File, int Ccarousel_level){
        return ResultCode.SUCCESS.result(carouselService.addCarousel(Ccarousel_level,File));
    }

    @ApiOperation(value = "修改轮播图图片等级",notes = "修改轮播图图片等级")
    @RequestMapping(value = "/reviseCarousel",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Object reviseCarousel( int carousel_id, int carousel_level,MultipartFile File){
        return ResultCode.SUCCESS.result(carouselService.reviseCarouselLevel(carousel_id,carousel_level, File));
    }

    @ApiOperation(value = "查询所有轮播图" ,notes = "查询所有轮播图 ")
    @RequestMapping(value = "/researchCarousel",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Object researchCarousel (){
        return ResultCode.SUCCESS.result(carouselService.researchCarousel());
    }

    @ApiOperation(value = "删除轮播图",notes = "删除轮播图")
    @RequestMapping(value = "/deleteCarousel",method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public Object deleteCarousel(int carousel_id){
        return ResultCode.SUCCESS.result(carouselService.deleteCarousel(carousel_id));
    }
}
